// shell.h
//	Shell for NachOS
//
//		When NachOS run, it go into this shell. Read & Parse & Execute Command
//
// Copyright (c) 2011 The Regents of the HuaZhong University of Technology.
// All rights reserved.  See copyright.h for copyright notice and limitation
// of liability and disclaimer of warranty provisions.

#ifndef SHELL_H
#define SHELL_H

#include "pair.h"
#include "list.h"
#include "builtins.h"

class GlobalEnvVarible;

typedef Pair<char*, char*> EnvVariable;
typedef Pair<char*, builtInFunc> BuiltInFunction;
typedef GlobalEnvVarible Alias;
					// Alias is part of EnvVariables

class GlobalEnvVarible {
public:
	GlobalEnvVarible()
	:variableCount(0) {
		envVariable = new List< EnvVariable *>();
	}
	~GlobalEnvVarible() {
		EnvVariable *e;
		for (int i = 0; i < variableCount; i++) {
			e = envVariable->RemoveFront();
			if (e->First() != NULL) {
				free(e->First());
			}
			if (e->Second() != NULL) {
				free(e->Second());
			}
		}
	}
	void Add(EnvVariable *item) {
		envVariable->Append(item);
	}
	void Delete(EnvVariable *item) {
		envVariable->Remove(item);
	}
private:
	int variableCount;
	List< EnvVariable* > *envVariable;
};


class Shell {
	Shell();
	~Shell();
};

#endif
